package com.app.mymvp.business.login;

import com.app.mymvp.entity.UserInfoEntity;

/**
 * Created by HJ on 2016-10-10.
 */

public class LoginModel implements LoginContract.Model {

    @Override
    public void login(final String username, final String password, final LoginContract.LoginListener listener) {
        //模拟子线程耗时操作
        new Thread() {
            @Override
            public void run() {
                try {
                    sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                //模拟登录成功
                if ("hj".equals(username) && "123".equals(password)) {
                    UserInfoEntity user = new UserInfoEntity();
                    user.setRealName(username);
                    listener.success(user);
                } else {
                    listener.fail();
                }
            }
        }.start();
    }
}
